package 动态规划;

import java.util.Arrays;

public class 礼物的最大价值 {

    public int maxValue(int[][] grid) {
        int row = grid.length;
        int col = grid[0].length;
        int sum = grid[0][0];
        int[][] dp = new int[row + 1][col + 1];
        //初始值
        // Arrays.fill(dp[1],sum);
        // for (int i = 0; i < row; i++) {
        //     dp[i][1]=sum;
        // }
        for (int i = 1; i < row+1; i++) {
            for (int j = 1; j < col+1; j++) {
                dp[i][j]=Math.max(dp[i-1][j],dp[i][j-1])+grid[i-1][j-1];
            }
        }
        return dp[row][col];
    }
}
